// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init({ env: 'cloud-9ged6fbx14ed7c19' }) // 使用当前云环境

// 云函数入口函数
exports.main = async (event, context) => {
  const wxContext = cloud.getWXContext()
  var arrayBuffer = event.arrayBuffer
  var contentType = event.contentType
  var buf = Buffer.from(arrayBuffer)

  try {
    return  await cloud.openapi.security.imgSecCheck({
      media: {
        contentType: contentType,
        value: buf
      }
    })
} catch (err) {
    return err;
}
/*
  return {
    event,
    openid: wxContext.OPENID,
    appid: wxContext.APPID,
    unionid: wxContext.UNIONID,
  }
  */

}